<template>
  <div>
    <el-dialog  class="dia-style" :title="title" :visible.sync="isOpen" width="60%" append-to-body>
      <el-row :gutter="15">
        <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
          <el-col :span="12">
            <el-row gutter="24">
              <el-col :span="24">
                <el-form-item label-width="120px" label="数据源名称" prop="name">
                  <el-input v-model="formData.name" placeholder="请输入数据源名称" clearable :style="{width: '100%'}">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="12">
            <el-row gutter="24">
              <el-col :span="24">
                <el-form-item label-width="120px" label="Topic" prop="topic">
                  <el-input v-model="formData.topic" placeholder="请输入Topic" clearable
                            :style="{width: '100%'}"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="12">
            <el-row gutter="24">
              <el-col :span="24">
                <el-form-item label-width="120px" label="Kafka服务IP" prop="ip">
                  <el-input v-model="formData.ip" placeholder="请输入Kafka服务IP" clearable
                            :style="{width: '100%'}"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="12">
            <el-row gutter="15">
              <el-col :span="24">
                <el-form-item label-width="120px" label="服务端口" prop="port">
                  <el-input v-model="formData.port" placeholder="请输入服务端口" clearable :style="{width: '100%'}">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="12">
            <el-row gutter="15">
              <el-col :span="24">
                <el-form-item label-width="120px" label="Kafka用户名" prop="user">
                  <el-input v-model="formData.user" placeholder="请输入Kafka用户名" clearable
                            :style="{width: '100%'}"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="12">
            <el-row gutter="15">
              <el-col :span="24">
                <el-form-item label-width="120px" label="kafka密码" prop="parssWord">
                  <el-input v-model="formData.parssWord" placeholder="请输入kafka密码" clearable
                            :style="{width: '100%'}"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="handleConfirm">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  inheritAttrs: false,
  components: {},
  props: {
    title:{
      type:String,
      default(){
        return '编辑'
      }
    }
  },
  data() {
    return {
      isOpen:false,
      formData: {
        name: undefined,
        topic: undefined,
        ip: undefined,
        port: undefined,
        user: undefined,
        parssWord: undefined,
      },
      rules: {
        name: [{
          required: true,
          message: '请输入数据源名称',
          trigger: 'blur'
        }],
        topic: [{
          required: true,
          message: '请输入Topic',
          trigger: 'blur'
        }],
        ip: [{
          required: true,
          message: '请输入Kafka服务IP',
          trigger: 'blur'
        }],
        port: [{
          required: true,
          message: '请输入服务端口',
          trigger: 'blur'
        }],
        user: [{
          required: true,
          message: '请输入Kafka用户名',
          trigger: 'blur'
        }],
        parssWord: [{
          required: true,
          message: '请输入kafka密码',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    onOpen() {},
    onClose() {
      this.$refs['elForm'].resetFields()
    },
    close() {
      this.$emit('update:visible', false)
    },
    handleConfirm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        this.close()
      })
    },
  }
}

</script>
<style>
</style>
